/*
 * @Author: yanjikun
 * @Date: 2022-05-16 11:26:12
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-06-13 15:22:20
 * @Description: file content
 */

import { api } from '@/api'
import { YAxios } from '@/utils/http/request'

export function roleCreate(params: API.RoleCreateParams) {
  return YAxios(
    {
      url: api.role,
      method: 'post',
      data: params,
    },
    { successMsg: '新增成功！' },
  )
}

export function roleListAll() {
  return YAxios<API.TableListType<API.RoleListResult>>({
    url: `${api.role}/listAll`,
    method: 'get',
  })
}

export function roleInfo(params: API.RoleInfoParams) {
  return YAxios<API.RoleListItem>({
    url: `${api.role}/${params.id}`,
    method: 'get',
    params,
  })
}

export function roleUpdate(params: API.RoleCreateParams) {
  return YAxios(
    {
      url: `${api.role}/${params.id}`,
      method: 'put',
      data: params,
    },
    { successMsg: '修改成功！' },
  )
}

export function roleDelete(params: API.RoleDeleteParams) {
  return YAxios(
    {
      url: `${api.role}/${params.id}`,
      method: 'delete',
      params,
    },
    { successMsg: '删除成功！' },
  )
}

export function roleListByOrg(params: API.OrganizationsAllRightsParams) {
  return YAxios<API.OrganizationsAllRights>({
    url: `${api.organizations}/${params.id}/rights`,
    method: 'get',
    params,
  })
}
